<?php

function sites_add($domain) {
    
  $data['domain'] = $domain;
  $data['administratorId'] = operators_get_id();
  $id = database_insert('sites', $data);
  
  $leftType   = 'site';
  $leftId     = $id;
  $rightType  = 'operator';
  $rightId    = operators_get_id();
  
  relations_add($leftType, $leftId, $rightType, $rightId, 'operator');
}

function sites_get_all() {
  
  $administratorId = operators_get_id();
  
  $query  = "SELECT * FROM `sites`";
  $data   = database_get_assoc($query);
  
  return $data;
  
}

function sites_remove($id) {
  relations_remove('site', $id, 'operator', operators_get_id());
  database_remove('sites', $id);
}
